package handle

import (
	"cooke-home/task-service/config"
	"log"
	"os"
	"path/filepath"

	"github.com/BurntSushi/toml"
)

var cfg config.Config
var configInitialized bool = false

func InitToml() {
	if configInitialized {
		log.Println("配置已初始化，跳过")
		return
	}

	log.Println("开始初始化配置...")
	cwd, err := os.Getwd()
	if err != nil {
		log.Fatal("Failed to get current working directory:", err)
	}

	configPath := filepath.Join(cwd+"/", "config", "config.toml")
	if _, err := toml.DecodeFile(configPath, &cfg); err != nil {
		log.Fatal("Failed to decode TOML file:", err)
	}

	configInitialized = true
	log.Println("配置初始化完成")
}

func init() {
}
